import type { NavigateFunction } from "react-router";

declare global {
  interface Window {
    $useNavigateCacheRouter: NavigateFunction;
  }
}

export const useNavigateCacheRouter = () => {
  const setNavigateCache = (navigate: NavigateFunction) => {
    window.$useNavigateCacheRouter = navigate;
  };

  const getNavigateCache = window.$useNavigateCacheRouter as NavigateFunction;

  return {
    setNavigateCache,
    getNavigateCache
  };
};
